# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=leveldb
pkgver=1.22
pkgrel=1
pkgdesc="A fast and lightweight key/value database library by Google"
url="https://github.com/google/leveldb"
arch="all"
license="BSD-3-Clause"
makedepends="cmake snappy-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/google/$pkgname/archive/$pkgver.tar.gz"

build() {
	mkdir build && cd build
	cmake .. \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DLEVELDB_BUILD_TESTS=ON \
		-DLEVELDB_INSTALL=ON \
		-DBUILD_SHARED_LIBS=ON
	make
}

check() {
	cd "$builddir"/build
	make test
}

package() {
	cd "$builddir"/build
	make DESTDIR="$pkgdir" install
	mkdir -p "$pkgdir"/usr/share/doc
	cp -a ../doc "$pkgdir"/usr/share/doc/$pkgname
}

sha512sums="f9bbf5f466e7f707b94e19261762319ea9f65d41911690e84f59098551e2e69beccf756a414d705ade74ee96fd979bdb8b94c171c6f2cc83873cbd4a9380dbab  leveldb-1.22.tar.gz"
